<?php

$num_columns	= 7;
$can_delete	= $this->auth->has_permission('School.Schoolhouse.Delete');
$can_edit		= $this->auth->has_permission('School.Schoolhouse.Edit');
$has_records	= isset($records) && is_array($records) && count($records);

if ($can_delete) {
    $num_columns++;
}
?>
<style type="text/css">
  #TB_window {top: 20%; left: 60%; margin-left: 0px; overflow: hidden;}
  .edit_tab{font-size: 12px; color: #337AB7;display: none;}
  .edit_tab i{display: inline-block;border-left: 1px solid #DCDCDC;height: 10px;margin: 0 5px;}
  .edit_tab span:hover{color: #A91500;cursor: pointer}
  .edit_tab_box{min-height: 17px;margin-top: 8px;width: 100px;}
.count_tabs .active{color: #000;}
.count_tabs i{display: inline-block;border-left: 1px solid #797979;height: 10px;margin: 0 12px;}
.count_tabs span{color: #797979; margin-left: 8px;}
.clearbtn-margin{margin-top: -3px;}
em{display: block; height: 15px;}
.column-check{width: 30px;}
.list-inline span:nth-child(2) {width: 100px;}
</style>
<section>
	<div class='content-header'>
	<h1 class="clearfix">
		专题页
	</h1>
	<em></em>
	<div class="count_tabs">
		<a href="?status=2" class="itemtype <?php if($type == 2){echo 'active';} ?>">已发布</a><span>(<?php echo $totalTrashNum;?>)</span><i></i><a href="?status=1" class="itemtype <?php if($type == 1){echo 'active';} ?>">草稿</a><span>(<?php echo $rubishNum;?>)</span>
  </div>
  <em></em>
  <form method="get">
  	<ul class="list-inline">
		<li>
			<select class="form-control select2" name="tags">
				<option value="0">全部标签</option>
                <?php if(isset($news_tag) && !empty($news_tag)) : ?>
                    <?php foreach ($news_tag as $news_tag) : ?>
                    <option value="<?php echo $news_tag->tag_name;?>"><?php echo $news_tag->tag_name;?></option>
                     <?php endforeach; ?>
                <?php endif;?>
			</select>
		</li>
		<li>
			<select class="form-control select2" name="category">
				<option value="0">全部分类</option>
                <?php foreach (news_category() as $key=>$news_cate) : ?>
                	<option value="<?php echo $key;?>"><?php echo $news_cate;?></option>
                <?php endforeach; ?>
			</select>
		</li>
		<li><button class="btn btn-default clearbtn-margin">筛选</button></li>
		<a href="/<?php echo SITE_AREA . '/subject/topic/create'; ?>" class="btn btn-success pull-right">╋   新增</a>

  	</ul>
  </form>
</section>
	

<section class="content">
  <div class="row">
    <div class="col-xs-12">
      <div class="nav-tabs-custom">

       <div class="box-body">
			<table id="example2" class="table table-striped table-hover" style="table-layout:fixed;">
				<thead>
					<tr>
						<th class='column-check'><input class='check-all' type='checkbox' /></th>
						<th>标题</th>
						<th>城市</th>
	                    <th>日期</th>
	                    <th>状态</th>
	                    <?php if($type == 1) :?>
						<th>操作</th>
	                    <?php endif;?>
					</tr>
				</thead>
				<?php if ($has_records) : ?>
				<tfoot>
					<?php if ($can_delete) : ?>
					<tr>
						
					</tr>
					<?php endif; ?>
				</tfoot>
				<?php endif; ?>
				<tbody>
					<?php
					if ($has_records) :
						foreach ($records as $record) :
					?>
					<tr class="item">
						<td class='column-check' style="word-wrap:break-word;"><input type='checkbox' name='checked[]' value='<?php echo $record->id; ?>' /></td>
						<td><a href="/<?php echo SITE_AREA . '/subject/topic/edit/' . $record->id; ?>"><?php e($record->title); ?></a>

	                    <?php if ($record->status == 3) : ?>
	            		<div class="edit_tab_box">
	                    	<div class="edit_tab">
                                <span>
                                <a href="/<?php echo SITE_AREA . '/subject/topic/changestatus/' . $record->id.'/type/2'; ?>" >还原</a>
                                </span><i></i>
                                <span>
                                <a href="/<?php echo SITE_AREA . '/subject/topic/changestatus/' . $record->id.'/type/3';  ?>"  style="cursor:pointer;color:#a00;" onclick="return confirm('确定要永久删除吗?');">永久删除</a>
                                </span>
	                        </div>
	                    </div>
	                    <?php else: ?>
	                    <div class="edit_tab_box">
	                        <div class="edit_tab">
                                <span>
                                <a href="/<?php echo SITE_AREA . '/subject/topic/edit/' . $record->id; ?>" >编辑</a>
                                </span><i></i>
                                <span>
                                <a href="/<?php echo SITE_AREA . '/subject/topic/changestatus/' . $record->id.'/type/1';  ?>"  style="cursor:pointer;color:#a00;" onclick="return confirm('确定放入垃圾箱吗?');">垃圾箱</a>
                                </span>
                                </div>
	                    </div>
	                    <?php endif; ?>
						</td>
						<td><?php e($record->cityname); ?></td>
		              	<td><?php e($record->create_time); ?></td>
		              	<td>
		              		<span class="label <?php if($record->status == 1) :?>label-warning<?php else :?>label-success<?php endif;?>"><?php e($record->showstatus); ?></span>
		              	</td> 
		              	<?php if($type == 1) :?>
						<td>
							<a href="/<?php echo SITE_AREA . '/subject/topic/publish/'. $record->id; ?>" class="btn btn-danger">一键发布</a>
						</td>
	                    <?php endif;?>
	   				</tr>
					<?php
						endforeach;
					else:
					?>
					<?php endif; ?>
				</tbody>
			</table>
		</div>
		<div class="box-footer">
			<div class="pull-right">
		    	<?php echo $this->pagination->create_links(); ?>
			</div>
		</div>
	<?php
    ?>
</div>
      </div>
      <!-- /.box -->
  </div>

</section>